import 'package:flutter/material.dart';
import 'package:flutter_color_plugin/flutter_color_plugin.dart';

class McourseItem extends StatelessWidget {
  final String title;
  final String subTitle;
  final String nickpicUrl;
  final String flagtext;

  McourseItem(this.title, this.subTitle, this.nickpicUrl, {this.flagtext = '微课'}) : super();

  // 副标题样式
  final TextStyle subtitleStyle = TextStyle(
      color: ColorUtil.color('#ABAFBF'),
      fontSize: 12,
      fontWeight: FontWeight.w500);

  // 主标题样式
  final TextStyle maintitleStyle = TextStyle(
      color: ColorUtil.color('#333333'),
      fontSize: 18,
      fontWeight: FontWeight.w500,
      height: 1.2);

  // 角标文字样式
  final TextStyle flagStyle = TextStyle(
    color: ColorUtil.color('#ffffff'),
    fontSize: 10,
    fontWeight: FontWeight.w500
  );

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.fromLTRB(0, 16, 0, 28),
      alignment: Alignment.center,
      child: Stack(
        overflow: Overflow.visible,
        children: <Widget>[
          Positioned(
            child: Container(
                width: 327,
                height: 125,
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(12),
                    boxShadow: [
                      BoxShadow(
                          color: Colors.black12,
                          blurRadius: 50.0,
                          spreadRadius: 2.0,
                          offset: Offset(0, 0)),
                    ]),
                child: Container(
                  padding: EdgeInsets.fromLTRB(114, 12, 12, 12),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Row(
                        children: <Widget>[
                          Container(
                            width: 30,
                            height: 15,
                            margin: EdgeInsets.only(right: 6.0),
                            decoration: BoxDecoration(
                              color: ColorUtil.color('#3F94EE'),
                              borderRadius: BorderRadius.all(Radius.circular(6)),
                            ),
                            child: Center(
                              child: Text(flagtext, style: flagStyle),
                            ),
                          ),
                          Text(title,
                              textAlign: TextAlign.left, style: subtitleStyle),
                        ],
                      ),
                      Divider(
                        color: Color.fromARGB(20, 150, 155, 175),
                        thickness: 1,
                        indent: 0,
                        endIndent: 46,
                      ),
                      Container(
                          width: 153,
                          child: Text(
                            subTitle,
                            style: maintitleStyle,
                            overflow: TextOverflow.visible,
                            textAlign: TextAlign.left,
                          )),
                      InkWell(
                        onTap: (){print('tap');},
                        child: Container(
                          width: 60,
                          height: 22,
                          margin: EdgeInsets.only(left: 140),
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(12)),
                            color: ColorUtil.color('#EC6958')
                          ),
                          alignment: Alignment.center,
                          child: Text('立即学习', style: TextStyle(color: Colors.white,fontSize: 12))
                        ),
                      )
                    ],
                  ),
                )),
          ),
          Positioned(
            bottom: 16,
            left: 15,
            child: Container(
              width: 84,
              height: 125,
              decoration: BoxDecoration(
                  color: Colors.grey,
                  shape: BoxShape.rectangle,
                  borderRadius: BorderRadius.circular(6.0),
                  image: DecorationImage(
                      image: NetworkImage(nickpicUrl), fit: BoxFit.cover)),
//              child: Image.network(nickpicUrl, fit: BoxFit.cover),
            ),
          )
        ],
      ),
    );
  }
}
